<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width">
	<title>{$row.name}</title>
	<meta name="Keywords" content="">
	<meta name="Description" content="">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/zhaomu.css"/>
	<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/questionnaire.css"/>
	<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/questionnaire1.css"/>
	<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/layer_mobile/layer.js"></script>
	<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/css/layer.css" />
	<script src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/jquery.1.9.1.js"></script>
	<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/rem.js"></script>
	<script type="text/javascript" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.js?v=1.2"></script>
	<link rel="stylesheet" type="text/css" href="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/js/address_select/mobileSelect.css?v=1.3" />
	<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
</head>
<body class="body_tj">
<script>
	wx.config({$jssdk});
	// wx.ready(function(){
	//   wx.hideMenuItems({
	//     menuList: ['menuItem:share:appMessage',"menuItem:share:timeline"]
	//   });
	// });
	wx.ready(function(){
		wx.hideOptionMenu()
	});
</script>
{if $row['is_source'] == 1}
<script>
   var referer_return = "{$referer_return}";
   var referer_url = "{$referer_url}";
	//非法来源注释
	if(!referer_return){
		layer.open({
			content: '请在直播间点击链接领取',//您未认真听讲或未认真答题，请重新答题
			skin: 'msg',
			time: 4,
		});
		setTimeout(function(){
			window.location.href = 'https://shoptest.fc62.com/index_activity/214';
		}, 4000);

	}
	console.log("来源  "+referer_url);
</script>
{/if}
{if $dati == 0}
<div id="wenjuanqqwe">
	<img style="width: 100%;" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/question_top6.jpg"/>


	<ul class="question">
		{foreach name="$info" item="vo"}
		<li>
			<p>{$key+1}. {$vo['name']} {if $vo['must_fil'] == 1}<span style="color: #ff0000;">*</span>{/if}</p>
			<input type="hidden" id="wenjuan{$key}" value="{$vo['must_fil']}" />
			<input type="hidden" id="wenjuantype{$key}" value="{$vo['type']}" />
			{if $vo['type'] == 1}
			{foreach name="$vo['timu']" key="k" item="v" }
			<p>
				<input  type="radio"  class="question-radio" name="wenjuan{$key}" id="a{$key}{$k}" value="{$vo['id']}-{$v['name']}-{$v['answer']}" />

				<label class="radio-label question-label" for="a{$key}{$k}"><span>{$v['name']}.{$v['answer']}</span></label>
			</p>
			{/foreach}
			{elseif $vo.type == 2}
			{foreach name="$vo['timu']" key="k" item="v" }
			<p>
				<input type="checkbox" name="wenjuan{$key}" id="a{$key}{$k}" value="{$vo['id']}-{$v['name']}-{$v['answer']}" />
				<label class="checkbox-label" for="a{$key}{$k}"><span>{$v['name']}.{$v['answer']}</span></label>
			</p>
			{/foreach}
			{/if}
		</li>
		{/foreach}

	</ul>

	<div class="question_mid">
		<p class="mid_top">感谢您的答题！祝孩子轻松学习、快乐成长！</p>
		<div>
			<p class="mid_mid">
			<p class="ktkj ylfx">提交问卷后，查看《小学生绘本课堂·素材书》电子版样张，并领取纸质版</p>
			<span class="question_submit">点击领取</span>
			</p>
		</div>
		<!--<p class="mid_bottom">* 语文为不公开领取，只公布电子版样张供家长参考</p>-->
	</div>
	<!-- <div class="question_mid">
        <img class="mid_img" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/mid_top.jpg"/>
        <img class="mid_img question_submit" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/mid_mid.jpg"/>
        <p class="mid_bottom">* 语文为不公开领取，只公布电子版样张供家长参考</p>
    </div> -->

</div>
<script>
	var count = {:count($info)};
	var jsonData={};
	$(function(){
		$('.question_submit').click(function(){


			for (var i = 0; i < count; i++) {
				var type= $("#wenjuantype"+i).val();
				console.log(type);
				if(type == 1){
					var wenjuan = $("input[name='wenjuan"+i+"']:checked").val();
				}else if(type == 2){
					var wenjuan = "";
					$("input[name='wenjuan"+i+"']:checked").each(function(){
						wenjuan += $(this).val() + "||";
					});
					if(wenjuan.length > 0){
						wenjuan = wenjuan.substring(0, wenjuan.length - 2); //把最后一个逗号去掉
					}
					console.log(wenjuan);
				}
				var must_fil= $("#wenjuan"+i).val();

				if(must_fil == 1){
					if(wenjuan == ""||wenjuan == null){
						layer.open({
							content: '请填写听课效果问卷后点击领取',
							skin: 'msg',
							time: 2 //2秒后自动关闭
						});
						return false;
					}
				}
				jsonData['wenjuan'+i] = wenjuan;
			}
			console.log(jsonData);
			$.ajax({
				type: 'post',
				url:"/index/ques/volumepost/ids/{$row['id']}" ,
				data:jsonData,
				success: function(data) {
					if (data.code == 0) {
						layer.open({
							content: data.msg,//您未认真听讲或未认真答题，请重新答题
							skin: 'msg',
							time: 2,
						});
						return false;
					} else {
						// layer.open({
						//   content: data.msg,//您未认真听讲或未认真答题，请重新答题
						//   skin: 'msg',
						//   time: 2,
						// });
						// setTimeout(function(){
						//     window.location.reload();
						// }, 2000);
						window.scroll(0, 0);
						window.location.reload();

					}
				}
			});
		});
	});
</script>
<!--问卷结束-->
{else}

{if !$edit}
<!-- add表单开始   -->
<div class="addressmone" style="display: block;">

	<div class="question_mid">
		<a href="http://uploadfile.fc62.com/ques/%E7%B4%A0%E6%9D%90%E4%B9%A6-1-6%E5%B9%B4%E7%BA%A7%E7%94%B5%E5%AD%90%E7%89%88%E6%A0%B7%E4%B9%A6.pdf"><img class="mid_img" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/question_mid4.jpg"/></a>
	</div>	<ul>
		<li>
			<p style="font-size: 0.3rem;color: #666;">纸质版领取,请选择送达方式并填写寄送地址</p>
			<div style="overflow: hidden;display: flex;flex-direction: row;justify-content:space-between;">

				<div style="margin-top: 0.2rem;">
					<input type="radio" name="way" id="way11" value="1" checked />
					<label class="radio-labels" for="way11"><span class="way">送学校（10天内送达）</span></label>
					<p class="radioinfo">*免邮费</p>
				</div>

				<div style="margin-top: 0.2rem;">
					<input type="radio" name="way" id="way22" value="2" />
					<label class="radio-labels" for="way22"><span class="way">寄到家（3天内寄出）</span></label>
					<p class="radioinfo">*9元邮费</p>
				</div>
			</div>
			<p style="font-size: 0.22rem;color: #666;margin-top: 0.4rem;">购买任意产品无需填写信息领取，赠品随购买产品免费寄达， 如有其他要求请在订单上备注。</p>
		</li>

		<li>
			<p class="form_con">学生姓名 <span style="color: #ff0000;">*</span></p>
			<input type="text" name="consignee" value="" id="name" >
			<img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_1.jpg"/>
		</li>
		<li>
			<p class="form_con">家长姓名 <span style="color: #ff0000;">*</span></p>
			<p class="tips">用于领书确认联络</p>
			<input type="text" name="parent_name" value="" id="parent_name" >
			<img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_1.jpg"/>
		</li>
		<li style="position: relative;">
			<p class="form_con">所在学校 <span style="color: #ff0000;">*</span></p>
			<div id="trigger5" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 100%;height: 35px;line-height: 35px;border-radius: 5px;overflow: hidden;">
				<span style="color: #666;">请选择</span>
			</div>
			<img style="position: absolute;bottom: 0.3rem;left: 92%;width: 0.26rem;height: 0.13rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png"/>
			<input type="hidden" name="" id="school" value="" />
			<input type="hidden" name="" id="classname" value="" />
		</li>
		<div class="hide" style="position: relative;">
			<img class="selectjt" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png" alt="">
			<select class="selectchoose" name="totalschool" id="totalschool" value="">
				<option value ="0">请选择学校</option>
				{foreach name="$base_school" item="vobasc"}
				<option value ="{$vobasc->id}">{$vobasc->name}</option>
				{/foreach}
			</select>
		</div>
		<li class="hide">
			<p class="form_con">班级 <span style="color: #ff0000;">*</span></p>
			<input type="text" value="" name="qitaclassname" id="qitaclassname">
			<img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_4.jpg"/>
		</li>
		<!--	<li style="position: relative;">
                <p class="form_con">所在学校 <span style="color: #ff0000;">*</span></p>
                <div id="trigger5" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 100%;height: 35px;line-height: 35px;border-radius: 5px;overflow: hidden;">
                    <span style="color: #666;">请选择学校</span>
                </div>
                <img style="position: absolute;bottom: 0.3rem;left: 92%;width: 0.26rem;height: 0.13rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png"/>
                <input type="hidden" name="" id="school" value="" />
                <input type="hidden" name="" id="classname" value="" />
            </li>

            <div class="hide" style="position: relative;">
                <img class="selectjt" src="https://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png" alt="">
                <select class="selectchoose" name="totalschool" id="totalschool" value="">
                    <option value ="0">请选择学校</option>
                    {foreach name="$base_school" item="vobasc"}
                    <option value ="{$vobasc->id}">{$vobasc->name}</option>
                    {/foreach}
                </select>
            </div>
            <li class="hide">
                <p class="form_con">班级 <span style="color: #ff0000;">*</span></p>
                <input type="text" name="qitaclassname" value="" id="qitaclassname" >
                <img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_4.jpg"/>
            </li>-->
		<li style="position: relative;">
			<p class="form_con">所在地区 <span style="color: #ff0000;">*</span></p>
			<div id="trigger4" class="trigger4" style="text-indent:0.5em;display: inline-block;border: 1px solid #ccc;width: 100%;height: 35px;line-height: 35px;border-radius: 5px;overflow: hidden;">
				<span style="color: #666;">请选择</span>
			</div>
			<img style="position: absolute;bottom: 0.3rem;left: 92%;width: 0.26rem;height: 0.13rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/tj.png"/>
			<input type="hidden" name="" id="sheng" value="" />
			<input type="hidden" name="" id="shi" value="" />
			<input type="hidden" name="" id="xian" value="" />
		</li>

		<li>
			<p class="form_con">详细地址 <span style="color: #ff0000;">*</span></p>
			<textarea name="address" id="address" placeholder="用户寄达赠书使用，请认真填写"></textarea>
		</li>
		<li>
			<p class="form_con">联系电话 <span style="color: #ff0000;">*</span></p>
			<input type="number" pattern="[0-9]*" name="" id="tel" value="" />
			<img style="bottom: 0.9rem;" src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_2.jpg"/>
			<input style="width: 59%;" type="number" name="" id="code" pattern="[0-9]*" value="" />
			<input type="button" class="huoqu" value="获取验证码">
			<img src="http://tmall.fc62.com/mobile/themesmobile/68ecshopcom_mobile/images/form_3.jpg"/>
		</li>
		<li>
			<p class="form_con">领取年级 <span style="color: #ff0000;">*</span></p>

			<div style="padding: 0.2rem 0;border-top: 1px solid #eee;">
				<div>
					<input type="radio" name="gra" id="grade1" value="1" checked />
					<label class="radio-labels" for="grade1"><span class="value">一年级</span></label>
					<input type="radio" name="gra" id="grade2" value="2" />
					<label class="radio-labels" for="grade2"><span class="value">二年级</span></label>
					<input type="radio" name="gra" id="grade3" value="3" />
					<label class="radio-labels" for="grade3"><span class="value value_right">三年级</span></label>
				</div>
				<div style="margin-top: 0.1rem;">
					<input type="radio" name="gra" id="grade4" value="4" />
					<label class="radio-labels" for="grade4"><span class="value">四年级</span></label>
					<input type="radio" name="gra" id="grade5" value="5" />
					<label class="radio-labels" for="grade5"><span class="value">五年级</span></label>
					<span class="six">
						<input type="radio" name="gra" id="grade6" value="6" />
						<label class="radio-labels" for="grade6"><span class="value value_right">六年级</span></label>
					</span>
				</div>
			</div>
			<p style="font-size: 0.22rem;color: #666;text-indent: -0.1rem;">（如遇库存缺货情况随机选送本年级下册或下一年级上册，领完为止）</p>
		</li>
	</ul>

	<div class="dotm_btn">
		<input type="submit" value="提交" class="dotm_btn1">
	</div>

</div>

<script>
	var volume_id = '{$row["id"]}';

	$(function(){

		var arrarea = [];
		var province = 1;
		var city = 2;
		var area = 3;
		var province_more = '';
		var city_more = '';
		var area_more = '';
		$.ajax({
			type: "post",
			url: "/api/ajax/area",
			dataType: "json",
			async: false,
			success: function(res){
				arrarea = res.data;
				console.log(arrarea);
			}
		});
		for (var i = 0; i < arrarea.length; i++) {
			if(province == arrarea[i]['id']){
				province_more = i;
				for (var s = 0; s < arrarea[i]['childs'].length; s++) {
					if(city == arrarea[i]['childs'][s]['id']){
						city_more = s;
						for (var a = 0; a < arrarea[i]['childs'][s]['childs'].length; a++) {
							if(area == arrarea[i]['childs'][s]['childs'][a]['id']){

								area_more = a;
							}
						}
					}
				}
			}
		}

		var mobileSelect4 = new MobileSelect({
			trigger: '#trigger4',
			title: '地区选择',
			wheels: [{data:arrarea}],
			position:[province_more,city_more,area_more],
			callback:function(indexArr, data){
				$('#sheng').val(data[0].id);
				$('#shi').val(data[1].id);
				$('#xian').val(data[2].id);
			}
		});
		$('input[name=way]').on('change',function () {
			if ($(this).val()==1){
				$('.dotm_btn1').val('提交')
			} else{
				$('.dotm_btn1').val('付9元邮费寄到家')

			}
		})
		//学校班级联动
		var mobileSelect5 = new MobileSelect({
			trigger: '#trigger5',
			title: '学校选择',
			wheels: [{data:[
					{
						id:'1',
						value:'',
						childs:[
							{id:'A1',value:''},
						]
					}
				]}],
			transitionEnd:function(indexArr, data){

			},
			callback:function(indexArr, data){
				console.log(data);
				$('#school').val(data[0].id);
				if(data[0].id == -1){
					$(".hide").show();
				}else{
					$('#classname').val(data[1].value);
					$(".hide").hide();
				}
			}
		});
		$.ajax({
			type: "get",
			url: "https://oa.fc62.com/api/ajax/ques_school/ids/"+volume_id,
			dataType: "json",
			success: function(res){
				var qita = {
					id:"-1",
					value:"错过本地领取的学校",
					childs:[]
				}
				res.data.push(qita);
				mobileSelect5.updateWheels(res.data);
			}
		});
		$("#system2").click(function(){
			$(".six").hide();
		})
		$("#system1").click(function(){
			$(".six").show();
		})
		//点击获取验证码
		$('.huoqu').click(function() {
			var tel = $('#tel').val();
			console.log(tel);
			if(!(/^1[3456789]\d{9}$/.test(tel))) {
				layer.open({
					content: '请输入正确的手机号码',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			$.ajax({
				type: 'post',
				url:"/api/sms/send" ,
				data:{mobile:tel,event:'schoolxiaoxue'},
				success: function(data){
					console.log(data);
					if(data.code != 1){
						layer.open({
							content:data.msg ,
							skin: 'msg',
							time: 2 //2秒后自动关闭
						});
						return false
					}else{
						var count = 120;
						const countDown = setInterval(() => {
							if (count === 0) {
								$('.huoqu').val('重新发送').removeAttr('disabled');
								$('.huoqu').css({
									background: '#f3494c',
									color: '#fff',
								});
								clearInterval(countDown);
							} else {

								$('.huoqu').css({
									background: '#eee',
									color: '#333',
								});
								$('.huoqu').val(count + '秒后可重新获取');
								$('.huoqu').attr('disabled', true);
							}
							count--;
						}, 1000);
					}
				}
			});
		});
		//点击提交按钮
		$('.dotm_btn1').click(function(){
			var ways=document.getElementsByName('way');
			let waysVal;
			for (var i = 0; i < ways.length; i++) {
				if (ways[i].checked)
					waysVal=ways[i].value;
			}
			var gra=document.getElementsByName('gra');
			let graVal;
			for (var i = 0; i < gra.length; i++) {
				if (gra[i].checked)
					graVal=gra[i].value;
			}

			var sheng = $('#sheng').val();
			var shi = $('#shi').val();
			var xian = $('#xian').val();
			var code = $('#code').val();
			var name = $('#name').val();//学生姓名
			var parent_name = $('#parent_name').val();
			var tel = $('#tel').val();
			var address = $('#address').val();
			var school = $('#school').val();//选择学校
			var totalschool = $('#totalschool').val();//全部学校
			var classname = $('#classname').val();//班级
			var qitaclassname = $('#qitaclassname').val();//班级
			//var type = $("input[name='type']:checked").val();//版本
			// var arr =[];
			// $('input[name="subject"]:checked').each(function(){
			// 	arr.push($(this).val());
			// });
			// var subject = arr.join();//学科
			if(name == ""||name == null){
				layer.open({
					content: '请填写学生姓名',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			if(parent_name == ""||parent_name == null){
				layer.open({
					content: '请填写家长姓名',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}

			if(school == ""||school == null){
				layer.open({
					content: '请选择学校',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}else if(school == -1){
				if(totalschool == 0){
					layer.open({
						content: '请选择学校',
						skin: 'msg',
						time: 2 //2秒后自动关闭
					});
					return false;
				}
				if(qitaclassname == ""||qitaclassname == null){
					layer.open({
						content: '请填写班级',
						skin: 'msg',
						time: 2 //2秒后自动关闭
					});
					return false;
				}else{
					classname = qitaclassname;
				}
			}
			if(sheng == ""||sheng == null){
				layer.open({
					content: '请选择所在地区',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			if(address == ""||address == null){
				layer.open({
					content: '请填写详细地址',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}


			if(!(/^1[3456789]\d{9}$/.test(tel))) {
				layer.open({
					content: '请输入正确的手机号码',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			if(code == ""||code == null){
				layer.open({
					content: '请填写验证码',
					skin: 'msg',
					time: 2 //2秒后自动关闭
				});
				return false;
			}
			// if(type == ""|| type == null){
			//     layer.open({
			//         content: '请选择领取版本',
			//         skin: 'msg',
			//         time: 2 //2秒后自动关闭
			//     });
			//     return false;
			// }



			var index = layer.open({type: 2});
			//验证验证码
			$.ajax({
				type: 'post',
				url:"/api/sms/check" ,
				data:{mobile:tel,captcha:code,event:'schoolxiaoxue'},
				success: function(data){
					if(data.code == 0){
						layer.close(index);
						layer.open({
							content: data.msg,
							skin: 'msg',
							time: 2,
						});
						return false;
					}else{
						//添加禁止标签
						$('.dotm_btn1').attr("disabled","disabled");
						$.ajax({
							type: 'post',
							url:"/index/ques/school" ,
							dataType:'json',
							data:{grade:graVal,pays:waysVal,shen:sheng,shi:shi,xian:xian,name:name,parent_name:parent_name,phone:tel,school:school,totalschool:totalschool,classname:classname,address:address,volume_id:volume_id},
							success: function(data){
								if(data.code == 0){
									layer.close(index);
									$('.dotm_btn1').attr("disabled","");
									layer.open({
										content: data.msg,
										skin: 'msg',
										time: 2,
									});
									return false;
								}else if(data.code==2){
									layer.close(index);
									wx.chooseWXPay({
										timestamp: data.timeStamp,
										nonceStr: data.nonceStr,
										package: data.package,
										signType: data.signType,
										paySign: data.paySign, // 支付签名
										success: function (res) {
											// 支付成功后的回调函数
											if (res.errMsg == "chooseWXPay:ok") {
												// alert('支付成功');
												window.location.href="https://shoptest.fc62.com/user/primaty_success";
												// window.location.reload();
												$('.dotm_btn1').removeAttr("disabled");
											} else {
												alert(res.errMsg,null);
												$('.dotm_btn1').removeAttr("disabled");
											}
										},
										cancel: function(r) {
											alert('取消支付');
											$('.dotm_btn1').removeAttr("disabled");
										},
										fail:function(r){
											alert('fail支付失败了');
											$('.dotm_btn1').removeAttr("disabled");
											//支付失败
										}

									});


								}else{
									console.log(data.data);

									layer.close(index);
									//var findlUrl = 'https://shoptest.fc62.com/activity/submit_success/32'
									window.location.href=data.data;
								}

							}
						});
						//提交表单

					}

				}
			});
		});

	});
</script>
<!--  add表单结束  -->
{else}

<!-- edit表单开始   -->
{/if}
{/if}

</body>

</html>
